import { EChartsOption } from "echarts"
import { jsonRequest } from "../../requests"

export class DataVisualizationRequests {
    componentName: string
    constructor(componentName: string) {
        this.componentName = componentName
    }

    public async getAllChartOptions() {
        return await jsonRequest.get<{ [key: string]: EChartsOption }>(`/api/${this.componentName}/chart_options`)
    }

    public async getAllChartStyleOptions() {
        return await jsonRequest.get<{ [key: string]: EChartsOption }>(`/api/${this.componentName}/chart_style_options`)
    }

    public async saveChartStyleConfig(chartName: string, config: EChartsOption) {
        return await jsonRequest.post(`/api/${this.componentName}/save_chart_style_config`, { chartName, config })
    }
}